<#-- 新建推荐 -->
<div id="modal"  style="display:none;">
<div class="modal">
	<div class="modal-header">
		<a class="close" data-dismiss="modal">×</a>
		<h3></h3>
	</div>
	<div class="modal-body">
		
	</div>
	<div class="modal-footer">
		<a class="btn cancel" data-dismiss="modal">取消</a> <a class="btn btn-primary modalSubmit" data-dismiss="modal"></i>确定</a>
	</div>
</div>

<div class="modal-backdrop fade in"></div>
</div>

<script type="text/javascript">
$.extend({
	modal:function(option, load,  callback, callbackParam){
		if(load){
			$("#modal .modal-body").loadHtml(load.url, load.param, load.type);
		}else{
			$("#modal .modal-body").html(option.body);
		}
		$("#modal .modal-header h3").text(option.title);
		$("#modal").fadeIn();
		$("#modal .modal .modalSubmit").click(function(){
			var flag = new Boolean(true);
			var size = $("input.required").size();
			var requiredName = new Array();
			for(var i = 0; i < size; i ++){
				var $required = $("input.required:eq(" + i + ")");
				if($required.val() == "" || $required.val() == null){
					flag = false;
					var label = $required.parent().siblings("label").html();
					requiredName.push(label);
					$required.siblings("span.requiredMsg").show();
				}
				else{
					$required.siblings("span.requiredMsg").hide();
				}
			}
			
			if(flag == true){
				callback($(this), callbackParam);
			}
		});
	},
	
	closeModal:function(){
		$("#modal").fadeOut();
		$("#modal .modal-header h3").text("");
		$("#modal .modal-body").html("");
		$("#modal .modal .modalSubmit").unbind("click");
	}
});

$(document).ready(function(){
	//点击后面的阴影时消失 关闭弹出摸框
	$(".modal .close").click(function(){
		$.closeModal();
	});
	$(".modal .cancel").click(function(){
		$.closeModal();
	});
	$(".modal-backdrop").click(function(){
		$.closeModal();
	});
});
</script>